local skel = fk.CreateSkill {
  name = "emo__yuanzhao",
}

Fk:loadTranslationTable{
  ["emo__yuanzhao"] = "怨沼",
  [":emo__yuanzhao"] = "出牌阶段限一次，你可以令任意名角色依次随机将一张牌交给其下家，你交出牌后摸一张牌。",

  ["#emo__yuanzhao"] = "怨沼：可以令任意名角色随机将一张牌交给其下家",
}

skel:addEffect("active", {
  anim_type = "control",
  prompt = "#emo__yuanzhao",
  card_num = 0,
  min_card_num = 1,
  target_filter = function (self, player, to_select, selected)
    return true -- not to_select:isNude()
  end,
  can_use = function(self, player)
    return player:usedSkillTimes(skel.name, Player.HistoryPhase) == 0
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    local tos = effect.tos
    room:sortByAction(tos)
    for _, to in ipairs(tos) do
      if not to.dead and not to:isNude() then
        local other = to:getNextAlive()---@type ServerPlayer
        if to ~= other then
          local cid = table.random(to:getCardIds("he"))
          room:obtainCard(other, cid, false, fk.ReasonGive, to, skel.name)
          if to == player and not player.dead then
            player:drawCards(1, skel.name)
          end
        end
      end
    end
  end,
})

return skel
